package com.itheima.Demo;

import com.itheima.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class demo01 {
    @Test
    public void Test01() throws IOException {
        // 1. 加载主配置文件 生成io流
        InputStream is = Resources.getResourceAsStream("sqlMapConfig.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = build.openSession();
        List<User> user = sqlSession.selectList("org.mybatis.example.BlogMapper.findAllUsers");
        user.forEach(user1 -> System.out.println(user1.toString()));
        sqlSession.close();
    }
}
